jQuery(document).ready(function($) {
	
	$('#SignInForm :submit').click(function() {
		var form = $(this).parents('form').get(0);
		var inpUsername = $(form).find('input:text[name=FormUsername]').val();
		var inpPassword = $(form).find('input:password[name=FormPassword]').val();
		var inpRemember = $(form).find('input:checkbox[name=FormRememberMe]:checked').val() == 1 ? true : false;
		$(form).find(':submit').attr('disabled', 'disabled');
		$.ajax({
			type: "POST",
			url: "ajax/signin/",
			data: 'Username=' + inpUsername + '&Password=' + inpPassword + '&RememberMe=' + inpRemember,
			dataType: "json",
			error: function(XMLHttpRequest, textStatus, errorThrown) {
				alert(textStatus);
			},
			success: function(json) {
				alert(json.Message);
			},
			complete: function(XMLHttpRequest, textStatus) {
				$(form).find(':submit').removeAttr('disabled');
			}
		});
		return false;
	});
	
});